# -*- coding: utf-8 -*-
"""
author:码同学 极光
date:2023-01-04
desc: 
sample: 
"""


name = "testfan"  #反转 -》字符串
# print(len(name))
# print(name[len(name)-1])

for i in range(len(name)-1,-1,-1):
    print(i)

print(name[len(name)-1])

#利用list 的反转方法
list1 = list(name)
list1.reverse()
print("".join(list1))
#有问题
#print("".join(list(name).reverse()))

#方法2
#reversed 函数
print("".join(reversed(name)))

#方法3
print(name[::-1])
#方法4
newName2=''
for  i in range(len(name)-1):   # 0....len(name)
    newName2 += name[len(name)-i]
print("range_正序", newName2)

 #方法5
newName=''
for  i in range(len(name)-1, -1, -1):  # len(name)-1...-1
    newName += name[i]
print("range_倒序", newName)









